#size
res<-300
width<-500*res/72
height<-4/5*width

color<-c('gray80','gray45')
space<-c(0,2)#spaces between pairs of bars
border<-T
lwd_border<-0.5

#grid
lwd_grid<-0.5
color_grid<-"black"

#Data

NotNRM<-c(33,33,47,40, 7)
NRM<-c(19,45,58,58, 6)

#Export to jpeg
tiff(filename = "figures_tables/FigA2_NRM.tif",
     width = width, 
     height =height,
     res=res,
     units = "px", 
     pointsize=9,
     bg = "white", 
     type = 'cairo')

par(mar=c(4,6,3,4)+0.1,lwd=lwd_border)

barplot(rbind(NotNRM, NRM), width=0.2, xlim=c(0,4.5), ylim=c(0,100),beside=T,
        col=color,,space=c(1.0,0,1.4,0,1.4,0,1.4,0,1.4,0))
        
abline(h=seq(0,100,20),col=color_grid,lwd=lwd_grid)
abline(h=0)
abline(h=100)

mtext(c('Lobbying', 'Bureaucratic \n Help', 'Monitoring \n & Oversight', 'Community \n Mobilization', 'Other'),side=1,line=2,at=c(0.3,1.0,1.7,2.4,3.1)+0.1)

barplot(rbind(NotNRM, NRM), width=0.2, xlim=c(0,4.5), ylim=c(0,100),beside=T,
        col=color,lwd=lwd_border,space=c(1.0,0,1.4,0,1.4,0,1.4,0,1.4,0),
        ylab='Percentage of politicians providing type of project support',add=T)


legend(0.05,100,
       legend=c('Opposition','NRM'),
       fill=c('gray80','gray45'),
       bty='n'
)

dev.off()